<%--
  Created by IntelliJ IDEA.
  User: 25326
  Date: 2024/9/13
  Time: 14:33
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
  <meta charset="utf-8">
  <title>编辑商品信息</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="${pageContext.request.contextPath}/lib/layui-v2.6.3/css/layui.css" media="all">
  <link rel="stylesheet" href="${pageContext.request.contextPath}/css/public.css" media="all">
</head>
<body>
<div class="layui-form layuimini-form">

  <div class="layui-form-item">
    <label class="layui-form-label">商品ID</label>
    <div class="layui-input-block">
      <input type="text" name="PId" value="${Product.PId}" class="layui-input" disabled>
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">商品名称</label>
    <div class="layui-input-block">
      <input type="text" name="PName" value="${Product.PName}" class="layui-input" >

    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label ">商品类型</label>
    <div class="layui-input-block">
      <select name="PType" lay-filter="PType" >
        <option value="女装男装" ${Product.PType=='女装男装'?'checked':''}>女装男装</option>
        <option value="鞋类箱包"${Product.PType=='鞋类箱包'?'checked':''}>鞋类箱包</option>
        <option value="护肤彩妆"${Product.PType=='护肤彩妆'?'checked':''}>护肤彩妆</option>
        <option value="汇吃美食"${Product.PType=='汇吃美食'?'checked':''}>汇吃美食</option>
        <option value="手机数码"${Product.PType=='手机数码'?'checked':''}>手机数码</option>
        <option value="其他产品"${Product.PType=='其他产品'?'checked':''}>其他产品</option>
      </select>
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">商品库存</label>
    <div class="layui-input-block">
      <input type="text" name="PNum" value="${Product.PNum}" class="layui-input" >
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">商品价格</label>
    <div class="layui-input-block">
      <input type="text" name="PPrice" value="${Product.PPrice}" class="layui-input" >
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">商品图片1</label>
    <div class="layui-input-block">
      <img width="400" height="200" src="${pageContext.request.contextPath}/${Product.PImage01}"/>
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">商品图片2</label>
    <div class="layui-input-block">
      <img width="400" height="200" src="${pageContext.request.contextPath}/${Product.PImage02}"/>
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">商品图片3</label>
    <div class="layui-input-block">
      <img width="400" height="200" src="${pageContext.request.contextPath}/${Product.PImage03}"/>
    </div>
  </div>


  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
    </div>
  </div>
</div>
<script src="${pageContext.request.contextPath}/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
  layui.use(['form'], function () {
    var form = layui.form,
            layer = layui.layer,
            $ = layui.$;

    //监听提交
    form.on('submit(saveBtn)', function (data) {
      var index = layer.alert(JSON.stringify(data.field), {
        title: '最终的提交信息'
      }, function () {

        // 关闭弹出层
        layer.close(index);

        var iframeIndex = parent.layer.getFrameIndex(window.name);
        parent.layer.close(iframeIndex);

      });

      return false;
    });

    form.on('submit(saveBtn)', function (data) {
      var data = JSON.stringify(data.field);

      $.post('${pageContext.request.contextPath}/ShopServlet?method=modifyGoods',{"data":data},function(data){
        if(data==1){
          layer.msg('修改成功',{icon:1})
          window.location = 'page/shopping/merchant/02_mygoods.jsp'
        }else{
          layer.msg('修改失败',{icon:2})
        }
      },"json")
      return false;
    });

  });
</script>
</body>
</html>